#ifndef		CALL_H
# define	CALL_H

# include	<QObject>
# include	<QtWidgets/QWidget>
# include	<QtWidgets/QMenu>
# include	<QtWidgets/QDialog>
# include	<QtWidgets/QPushButton>
# include	<QtWidgets/QVBoxLayout>
# include	<QtWidgets/QHBoxLayout>
# include	<QtWidgets/QLabel>
# include	<QtWidgets/QLineEdit>
# include	<iostream>
# include	"call_global.h"
# include	"IOrder.h"
# include	"IModule.h"
# include	"BabelApi.h"
# include	"ISoundPacket.h"

#if defined __linux__
class  Call : public QObject, public IModule
#else
class __declspec(dllexport)			Call : public QObject, public IModule
#endif
{
	Q_OBJECT

public:
	enum							Operator : byte
	{
		SOUND = 1,
		CALL = 2,
		CONNECT = 9,
 		ENDCALL = 10
	};

	Call();
	virtual ~Call();
	virtual void					takeOrder(IOrder *, Protocol);
	virtual void					test();
	virtual std::vector<Protocol>	getProtocol() const;
	virtual void					setApi(BabelApi *);
	virtual void					init();

public slots:
	void							inputReady(ISoundPacket *packet);
	void							OnCallButtonClicked();
	void							OnHangUpButtonClicked();
	void							OnCallActionTriggered();
	void							OnHangUpActionTriggered();
	void							selectedClient(unsigned int);

private:
	std::map<Operator, void (Call::*)(IOrder *)>		_operator;
	BabelApi						*_api;
	std::vector<Protocol>			_proto;
	QMenu							*_menu;
	QPushButton						*_buttoncall;
	QPushButton						*_buttonhangup;
	QAction							*_call;
	QAction							*_hangup;
	unsigned int					_clientSelected;
	bool							_isCall;
	unsigned int					_idCall;

private:
	void							addMenuCall();
	void							addButtonCall();
	void							addButtonHangup();
	void							sound(IOrder*);
	void							call(IOrder*);
	void							opConnect(IOrder *);
	void							endCall(IOrder *order);
};

#endif // CALL_H
